<?php

namespace App\Console\Commands\OpenShop;

use App\Models\Common\ConfigModel;
use App\Service\OpenShop\Statistical\SignOrderStatisticalService;
use Guanguans\Notify\Factory;
use Guanguans\Notify\Messages\FeiShu\CardMessage;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class OpenShopProvincialNotice extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'open_shop:provincial_robot_notice {env=prod}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '省区机器人推送';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     * 文档 https://onepiece-group.feishu.cn/wiki/wikcnBeaa6uy7Xs47EtssEnt9cf
     * @return int
     * @throws \Exception
     */
    public function handle()
    {
        $date = date('Y-m-d', strtotime('-1 day'));

        //全国
        self::nation($date);

        //重点城市
        $importantCityConfigList = ConfigModel::query()
                                              ->where('module', 'tigerRobot')
                                              ->where('name', 'robot')
                                              ->get()
                                              ->map(
                                                  function ($robot) {
                                                      return json_decode($robot->value, true) ?? [];
                                                  }
                                              )->toArray();

        self::importantCity($date, $importantCityConfigList);

        //分公司
//        self::branch($date);

        //当月开发确址排行榜--对应分公司分别推送
        self::branchRank($date, $importantCityConfigList);
    }

    //全国
    public function nation($date)
    {
        $data = SignOrderStatisticalService::getMonthProvincialData();
        if ($data['totalData']) {

            $totalData = $data['totalData'];

            $card = [
                "elements" => [
                    [
                        "tag"     => "markdown",
                        "content" => "**数据日报：{$date}**\n"
                    ],

                    [
                        "tag"     => "markdown",
                        "content" => "**业绩概览（单位：W）**"
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "grey",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**GMV**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**实收**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**堂食**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**外卖**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**占比**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "default",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['gmvTotal']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['totalAmount']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['totalCanteenAmount']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['dayWaimaiTotalAmount']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['waimaiRate']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],

                    [
                        "tag" => "hr"
                    ],

                    [
                        "tag"     => "markdown",
                        "content" => "**门店增长：**"
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "grey",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**DAU**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**WAU**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**MAU**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**AU**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "default",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['dauShopTotal']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['wau']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['mau']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['au']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "grey",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**好店**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**瘦狗**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**问题**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**ST**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "default",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['starShopRate']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['normalShopRate']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['problemShopRate']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['stShopRate']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],

                    [
                        "tag" => "hr"
                    ],

                    [
                        "tag"     => "markdown",
                        "content" => "**新开门店：**"
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "grey",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**已开**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**目标**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**完成率**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "default",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['monthRealNewNumber']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['monthDoNewTarget']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['monthRealNewRate']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],

                    [
                        "tag" => "hr"
                    ],

                    [
                        "tag"     => "markdown",
                        "content" => "**新签门店：**"
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "grey",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**已签**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**目标**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**完成率**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "default",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['newSignShopTotal']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['newSignTargetShopTotal']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['newSignShopRate']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],

                    [
                        "tag" => "hr"
                    ],

                    [
                        "tag"     => "markdown",
                        "content" => "**选址门店： {$totalData['siteTotal']}**"
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "grey",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**本月确址**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**活跃客户**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**定向选址**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**暂无计划**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**高流失**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "default",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['newSiteShopTotal']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['activeSiteTotal']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['directionalSiteTotal']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['silentSiteTotal']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['lossSiteTotal']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],

                    [
                        "tag" => "hr"
                    ],

                    [
                        "tag"     => "markdown",
                        "content" => "**筹备门店：{$totalData['preTotalNumber']}**"
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "grey",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**正常筹备**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**异常筹备**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**异常占比**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "default",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['preNormalNumber']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['preAbnormalNumber']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['preAbnormalRate']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "grey",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**统一开业**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**缺乏合同**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**未撤场**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**其他原因**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "default",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['unifiedOpenTotal']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['noContractTotal']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['notWithdrawnTotal']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['otherReasonTotal']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],

                    [
                        "tag"     => "markdown",
                        "content" => "**本月筹备**"
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "grey",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**正常筹备**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**异常筹备**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**预计开业**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "default",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['monthPreNormalNumber']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['monthPreAbnormalNumber']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['monthDoNewNumber']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "grey",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**统一开业**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**缺乏合同**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**未撤场**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**其他原因**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "default",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['unifiedOpenMonth']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['noContractMonth']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['notWithdrawnMonth']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['otherReasonMonth']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                        ]
                    ],


                    [
                        "tag" => "hr"
                    ],

                    [
                        "tag"     => "markdown",
                        "content" => "**休眠概览**"
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "grey",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**上月休眠数**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**休眠占比**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**核心**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "**发展**",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                'tag'            => 'column',
                                'width'          => 'weighted',
                                'weight'         => 1,
                                'vertical_align' => 'top',
                                'elements'       => [
                                    [
                                        'tag'        => 'markdown',
                                        'content'    => '**不发展**',
                                        'text_align' => 'center'
                                    ]
                                ]
                            ],
                        ]
                    ],
                    [
                        "tag"              => "column_set",
                        "flex_mode"        => "none",
                        "background_style" => "default",
                        "columns"          => [
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['lastMonthDormancyShopTotal']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['dormancyShopRate']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['dormancyShopRateKeyCity']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                "tag"            => "column",
                                "width"          => "weighted",
                                "weight"         => 1,
                                "vertical_align" => "top",
                                "elements"       => [
                                    [
                                        "tag"        => "markdown",
                                        "content"    => "{$totalData['dormancyShopRateOtherCity']}",
                                        "text_align" => "center"
                                    ]
                                ]
                            ],
                            [
                                'tag'            => 'column',
                                'width'          => 'weighted',
                                'weight'         => 1,
                                'vertical_align' => 'top',
                                'elements'       => [
                                    [
                                        'tag'        => 'markdown',
                                        'content'    => "{$totalData['notDevelopShopRateOtherCity']}",
                                        'text_align' => 'center'
                                    ]
                                ]
                            ],
                        ]
                    ],
                ]
            ];

            $robot = self::getRobot();
            Factory::feiShu()
                   ->setToken($robot['urlToken'])
                   ->setSecret($robot['secret'])
                   ->setMessage(new CardMessage($card))
                   ->send();
        }
        logInfo("全国数据推送完成", collect([]), true, true);
    }

    //重点城市
    public function importantCity($date, $importantCityConfigList)
    {
        if ($importantCityConfigList) {
            foreach ($importantCityConfigList[0] as $cityArrays) {
                foreach ($cityArrays['cityList'] as $city) {
                    if (!$city) {
                        continue;
                    }
                    $importantCityData = SignOrderStatisticalService::getMonthProvincialData($city);
                    if ($importantCityData['totalData']) {

                        $totalData = $importantCityData['totalData'];

                        $card = [
                            "elements" => [
                                [
                                    "tag"     => "markdown",
                                    "content" => "**{$city} 数据日报：{$date}**\n"
                                ],

                                [
                                    "tag"     => "markdown",
                                    "content" => "**业绩概览（单位：W）**"
                                ],
                                [
                                    "tag"              => "column_set",
                                    "flex_mode"        => "none",
                                    "background_style" => "grey",
                                    "columns"          => [
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**GMV**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**实收**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**堂食**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**外卖**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**占比**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                    ]
                                ],
                                [
                                    "tag"              => "column_set",
                                    "flex_mode"        => "none",
                                    "background_style" => "default",
                                    "columns"          => [
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['gmvTotal']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['totalAmount']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['totalCanteenAmount']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['dayWaimaiTotalAmount']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['waimaiRate']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                    ]
                                ],

                                [
                                    "tag" => "hr"
                                ],

                                [
                                    "tag"     => "markdown",
                                    "content" => "**门店增长：**"
                                ],
                                [
                                    "tag"              => "column_set",
                                    "flex_mode"        => "none",
                                    "background_style" => "grey",
                                    "columns"          => [
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**DAU**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**好店**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**瘦狗**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**问题**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**ST**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                    ]
                                ],
                                [
                                    "tag"              => "column_set",
                                    "flex_mode"        => "none",
                                    "background_style" => "default",
                                    "columns"          => [
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['dauShopTotal']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['starShopRate']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['normalShopRate']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['problemShopRate']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['stShopRate']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                    ]
                                ],

                                [
                                    "tag" => "hr"
                                ],

                                [
                                    "tag"     => "markdown",
                                    "content" => "**新开门店：**"
                                ],
                                [
                                    "tag"              => "column_set",
                                    "flex_mode"        => "none",
                                    "background_style" => "grey",
                                    "columns"          => [
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**已开**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**目标**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**完成率**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                    ]
                                ],
                                [
                                    "tag"              => "column_set",
                                    "flex_mode"        => "none",
                                    "background_style" => "default",
                                    "columns"          => [
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['monthRealNewNumber']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['monthDoNewTarget']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['monthRealNewRate']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                    ]
                                ],

                                [
                                    "tag" => "hr"
                                ],

                                [
                                    "tag"     => "markdown",
                                    "content" => "**新签门店：**"
                                ],
                                [
                                    "tag"              => "column_set",
                                    "flex_mode"        => "none",
                                    "background_style" => "grey",
                                    "columns"          => [
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**已签**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**线索**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                    ]
                                ],
                                [
                                    "tag"              => "column_set",
                                    "flex_mode"        => "none",
                                    "background_style" => "default",
                                    "columns"          => [
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['newSignShopTotal']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['clueNumTotal']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                    ]
                                ],

                                [
                                    "tag" => "hr"
                                ],

                                [
                                    "tag"     => "markdown",
                                    "content" => "**选址门店： {$totalData['siteTotal']}**"
                                ],
                                [
                                    "tag"              => "column_set",
                                    "flex_mode"        => "none",
                                    "background_style" => "grey",
                                    "columns"          => [
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**本月确址**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**活跃客户**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**定向选址**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**暂无计划**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**高流失**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                    ]
                                ],
                                [
                                    "tag"              => "column_set",
                                    "flex_mode"        => "none",
                                    "background_style" => "default",
                                    "columns"          => [
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['newSiteShopTotal']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['activeSiteTotal']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['directionalSiteTotal']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['silentSiteTotal']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['lossSiteTotal']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                    ]
                                ],

                                [
                                    "tag" => "hr"
                                ],

                                [
                                    "tag"     => "markdown",
                                    "content" => "**筹备门店：{$totalData['preTotalNumber']}**"
                                ],
                                [
                                    "tag"              => "column_set",
                                    "flex_mode"        => "none",
                                    "background_style" => "grey",
                                    "columns"          => [
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**正常筹备**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**异常筹备**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**异常占比**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                    ]
                                ],
                                [
                                    "tag"              => "column_set",
                                    "flex_mode"        => "none",
                                    "background_style" => "default",
                                    "columns"          => [
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['preNormalNumber']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['preAbnormalNumber']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['preAbnormalRate']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                    ]
                                ],

                                [
                                    "tag"     => "markdown",
                                    "content" => "**本月筹备**"
                                ],
                                [
                                    "tag"              => "column_set",
                                    "flex_mode"        => "none",
                                    "background_style" => "grey",
                                    "columns"          => [
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**正常筹备**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**异常筹备**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "**预计开业**",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                    ]
                                ],
                                [
                                    "tag"              => "column_set",
                                    "flex_mode"        => "none",
                                    "background_style" => "default",
                                    "columns"          => [
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['monthPreNormalNumber']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['monthPreAbnormalNumber']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                        [
                                            "tag"            => "column",
                                            "width"          => "weighted",
                                            "weight"         => 1,
                                            "vertical_align" => "top",
                                            "elements"       => [
                                                [
                                                    "tag"        => "markdown",
                                                    "content"    => "{$totalData['monthDoNewNumber']}",
                                                    "text_align" => "center"
                                                ]
                                            ]
                                        ],
                                    ]
                                ],

                            ]
                        ];

                        if (self::isProd()) {
                            $robot = [
                                'url'      => $cityArrays['robotUrl'],
                                'urlToken' => substr($cityArrays['robotUrl'],
                                    (strripos($cityArrays['robotUrl'], '/') + 1)),
                                'secret'   => $cityArrays['robotToken']
                            ];
                        } else {
                            $robot = self::getQaRobot();
                            continue;
                        }
                        Factory::feiShu()
                               ->setToken($robot['urlToken'])
                               ->setSecret($robot['secret'])
                               ->setMessage(new CardMessage($card))
                               ->send();
                    }
                }
            }

            logInfo("重点城市数据推送完成", collect([]), true, true);
        }
    }


    //分公司
    public function branch($date)
    {
        $branchData = SignOrderStatisticalService::getMonthBranchData();
        if ($branchData) {

            $card = [
                "elements" => [
                    [
                        "tag"     => "markdown",
                        "content" => "**目标追踪：{$date}**\n"
                    ],
                ]
            ];

            if ($branchData['newSignData']) {
                $card['elements'] = array_merge(
                    $card['elements'],
                    [
                        [
                            "tag" => "hr"
                        ],

                        [
                            "tag"  => "div",
                            "text" => [
                                "content" => " **签约门店数排行榜**",
                                "tag"     => "lark_md"
                            ]
                        ],

                        [
                            "tag"              => "column_set",
                            "flex_mode"        => "none",
                            "background_style" => "default",
                            "columns"          => [
                                [
                                    "tag"            => "column",
                                    "width"          => "weighted",
                                    "weight"         => 2,
                                    "vertical_align" => "top",
                                    "elements"       => [
                                        [
                                            "tag"  => "div",
                                            "text" => [
                                                "content" => "**名次**",
                                                "tag"     => "lark_md"
                                            ]
                                        ]
                                    ]
                                ],
                                [
                                    "tag"            => "column",
                                    "width"          => "weighted",
                                    "weight"         => 3,
                                    "vertical_align" => "top",
                                    "elements"       => [
                                        [
                                            "tag"  => "div",
                                            "text" => [
                                                "content" => "**分公司**",
                                                "tag"     => "lark_md"
                                            ]
                                        ]
                                    ]
                                ],
                                [
                                    "tag"            => "column",
                                    "width"          => "weighted",
                                    "weight"         => 5,
                                    "vertical_align" => "top",
                                    "elements"       => [
                                        [
                                            "tag"  => "div",
                                            "text" => [
                                                "content" => "**门店数**",
                                                "tag"     => "lark_md"
                                            ]
                                        ]
                                    ]
                                ],
                            ]
                        ]
                    ]
                );
                foreach ($branchData['newSignData'] as $k => $v) {
                    $sort             = $k + 1;
                    $card['elements'] = array_merge(
                        $card['elements'], [
                            [
                                "tag"              => "column_set",
                                "flex_mode"        => "none",
                                "background_style" => "default",
                                "columns"          => [
                                    [
                                        "tag"            => "column",
                                        "width"          => "weighted",
                                        "weight"         => 2,
                                        "vertical_align" => "top",
                                        "elements"       => [
                                            [
                                                "tag"  => "div",
                                                "text" => [
                                                    "content" => "NO.{$sort}",
                                                    "tag"     => "plain_text"
                                                ]
                                            ]
                                        ]
                                    ],
                                    [
                                        "tag"            => "column",
                                        "width"          => "weighted",
                                        "weight"         => 3,
                                        "vertical_align" => "top",
                                        "elements"       => [
                                            [
                                                "tag"  => "div",
                                                "text" => [
                                                    "content" => "{$v['branch']}",
                                                    "tag"     => "plain_text"
                                                ]
                                            ]
                                        ]
                                    ],
                                    [
                                        "tag"            => "column",
                                        "width"          => "weighted",
                                        "weight"         => 5,
                                        "vertical_align" => "top",
                                        "elements"       => [
                                            [
                                                "tag"  => "div",
                                                "text" => [
                                                    "content" => "{$v['newSignShop']}",
                                                    "tag"     => "plain_text"
                                                ]
                                            ]
                                        ]
                                    ],
                                ]
                            ]
                        ]
                    );
                }
            }

            if ($branchData['newRealNewData']) {
                $card['elements'] = array_merge(
                    $card['elements'], [
                        [
                            "tag" => "hr"
                        ],

                        [
                            "tag"  => "div",
                            "text" => [
                                "content" => " **新开门店数排行榜**",
                                "tag"     => "lark_md"
                            ]
                        ],
                        [
                            "tag"              => "column_set",
                            "flex_mode"        => "none",
                            "background_style" => "default",
                            "columns"          => [
                                [
                                    "tag"            => "column",
                                    "width"          => "weighted",
                                    "weight"         => 2,
                                    "vertical_align" => "top",
                                    "elements"       => [
                                        [
                                            "tag"  => "div",
                                            "text" => [
                                                "content" => "**名次**",
                                                "tag"     => "lark_md"
                                            ]
                                        ]
                                    ]
                                ],
                                [
                                    "tag"            => "column",
                                    "width"          => "weighted",
                                    "weight"         => 3,
                                    "vertical_align" => "top",
                                    "elements"       => [
                                        [
                                            "tag"  => "div",
                                            "text" => [
                                                "content" => "**分公司**",
                                                "tag"     => "lark_md"
                                            ]
                                        ]
                                    ]
                                ],
                                [
                                    "tag"            => "column",
                                    "width"          => "weighted",
                                    "weight"         => 3,
                                    "vertical_align" => "top",
                                    "elements"       => [
                                        [
                                            "tag"  => "div",
                                            "text" => [
                                                "content" => "**门店数**",
                                                "tag"     => "lark_md"
                                            ]
                                        ]
                                    ]
                                ],
                                [
                                    "tag"            => "column",
                                    "width"          => "weighted",
                                    "weight"         => 3,
                                    "vertical_align" => "top",
                                    "elements"       => [
                                        [
                                            "tag"  => "div",
                                            "text" => [
                                                "content" => "**完成率**",
                                                "tag"     => "lark_md"
                                            ]
                                        ]
                                    ]
                                ]
                            ]
                        ]
                    ]
                );
                foreach ($branchData['newRealNewData'] as $k => $v) {
                    $sort             = $k + 1;
                    $card['elements'] = array_merge(
                        $card['elements'], [
                            [
                                "tag"              => "column_set",
                                "flex_mode"        => "none",
                                "background_style" => "default",
                                "columns"          => [
                                    [
                                        "tag"            => "column",
                                        "width"          => "weighted",
                                        "weight"         => 2,
                                        "vertical_align" => "top",
                                        "elements"       => [
                                            [
                                                "tag"  => "div",
                                                "text" => [
                                                    "content" => "NO.{$sort}",
                                                    "tag"     => "plain_text"
                                                ]
                                            ]
                                        ]
                                    ],
                                    [
                                        "tag"            => "column",
                                        "width"          => "weighted",
                                        "weight"         => 3,
                                        "vertical_align" => "top",
                                        "elements"       => [
                                            [
                                                "tag"  => "div",
                                                "text" => [
                                                    "content" => "{$v['branch']}",
                                                    "tag"     => "plain_text"
                                                ]
                                            ]
                                        ]
                                    ],
                                    [
                                        "tag"            => "column",
                                        "width"          => "weighted",
                                        "weight"         => 3,
                                        "vertical_align" => "top",
                                        "elements"       => [
                                            [
                                                "tag"  => "div",
                                                "text" => [
                                                    "content" => "{$v['monthRealNewNumber']}",
                                                    "tag"     => "plain_text"
                                                ]
                                            ]
                                        ]
                                    ],
                                    [
                                        "tag"            => "column",
                                        "width"          => "weighted",
                                        "weight"         => 3,
                                        "vertical_align" => "top",
                                        "elements"       => [
                                            [
                                                "tag"  => "div",
                                                "text" => [
                                                    "content" => "{$v['monthRealNewRate']}",
                                                    "tag"     => "plain_text"
                                                ]
                                            ]
                                        ]
                                    ]
                                ]
                            ]
                        ]
                    );
                }
            }

            $robot = self::getBranchRobot();
            Factory::feiShu()
                   ->setToken($robot['urlToken'])
                   ->setSecret($robot['secret'])
                   ->setMessage(new CardMessage($card))
                   ->send();

            logInfo("分公司数据推送完成", collect([]), true, true);
        }
    }

    //当月开发确址排行榜--对应分公司分别推送
    public function branchRank($date, $importantCityConfigList)
    {
        $developRankData = SignOrderStatisticalService::getMonthDevelopRankData();
        if ($developRankData['totalData'] && $importantCityConfigList) {
            foreach ($importantCityConfigList[0] as $branchList) {
                foreach ($branchList['branch'] as $branch) {
                    if (isset($developRankData['totalData'][$branch]) && $developRankData['totalData'][$branch]) {
                        $card['elements'] = [
                            [
                                "tag"  => "div",
                                "text" => [
                                    "content" => " **当月开发确址排行榜 {$branch} **",
                                    "tag"     => "lark_md"
                                ]
                            ],

                            [
                                "tag"              => "column_set",
                                "flex_mode"        => "none",
                                "background_style" => "default",
                                "columns"          => [
                                    [
                                        "tag"            => "column",
                                        "width"          => "weighted",
                                        "weight"         => 5,
                                        "vertical_align" => "top",
                                        "elements"       => [
                                            [
                                                "tag"  => "div",
                                                "text" => [
                                                    "content" => "**开发经理**",
                                                    "tag"     => "lark_md"
                                                ]
                                            ]
                                        ]
                                    ],
                                    [
                                        "tag"            => "column",
                                        "width"          => "weighted",
                                        "weight"         => 2,
                                        "vertical_align" => "top",
                                        "elements"       => [
                                            [
                                                "tag"  => "div",
                                                "text" => [
                                                    "content" => "**确址**",
                                                    "tag"     => "lark_md"
                                                ]
                                            ]
                                        ]
                                    ],
                                    [
                                        "tag"            => "column",
                                        "width"          => "weighted",
                                        "weight"         => 2,
                                        "vertical_align" => "top",
                                        "elements"       => [
                                            [
                                                "tag"  => "div",
                                                "text" => [
                                                    "content" => "**目标**",
                                                    "tag"     => "lark_md"
                                                ]
                                            ]
                                        ]
                                    ],
                                    [
                                        "tag"            => "column",
                                        "width"          => "weighted",
                                        "weight"         => 3,
                                        "vertical_align" => "top",
                                        "elements"       => [
                                            [
                                                "tag"  => "div",
                                                "text" => [
                                                    "content" => "**完成率**",
                                                    "tag"     => "lark_md"
                                                ]
                                            ]
                                        ]
                                    ],
                                ]
                            ]
                        ];
                        foreach ($developRankData['totalData'][$branch] as $v) {
                            $card['elements'] = array_merge(
                                $card['elements'], [
                                    [
                                        "tag"              => "column_set",
                                        "flex_mode"        => "none",
                                        "background_style" => "default",
                                        "columns"          => [
                                            [
                                                "tag"            => "column",
                                                "width"          => "weighted",
                                                "weight"         => 5,
                                                "vertical_align" => "top",
                                                "elements"       => [
                                                    [
                                                        "tag"  => "div",
                                                        "text" => [
                                                            "content" => "{$v['nickname']}",
                                                            "tag"     => "plain_text"
                                                        ]
                                                    ]
                                                ]
                                            ],
                                            [
                                                "tag"            => "column",
                                                "width"          => "weighted",
                                                "weight"         => 2,
                                                "vertical_align" => "top",
                                                "elements"       => [
                                                    [
                                                        "tag"  => "div",
                                                        "text" => [
                                                            "content" => "{$v['siteShop']}",
                                                            "tag"     => "plain_text"
                                                        ]
                                                    ]
                                                ]
                                            ],
                                            [
                                                "tag"            => "column",
                                                "width"          => "weighted",
                                                "weight"         => 2,
                                                "vertical_align" => "top",
                                                "elements"       => [
                                                    [
                                                        "tag"  => "div",
                                                        "text" => [
                                                            "content" => "{$v['taskNum']}",
                                                            "tag"     => "plain_text"
                                                        ]
                                                    ]
                                                ]
                                            ],
                                            [
                                                "tag"            => "column",
                                                "width"          => "weighted",
                                                "weight"         => 3,
                                                "vertical_align" => "top",
                                                "elements"       => [
                                                    [
                                                        "tag"  => "div",
                                                        "text" => [
                                                            "content" => "{$v['rate']}",
                                                            "tag"     => "plain_text"
                                                        ]
                                                    ]
                                                ]
                                            ],
                                        ]
                                    ]
                                ]
                            );
                        }

                        if (self::isProd()) {
                            $robot = [
                                'url'      => $branchList['robotUrl'],
                                'urlToken' => substr($branchList['robotUrl'],
                                    (strripos($branchList['robotUrl'], '/') + 1)),
                                'secret'   => $branchList['robotToken']
                            ];
                        } else {
                            $robot = self::getQaRobot();
                        }
                        Factory::feiShu()
                               ->setToken($robot['urlToken'])
                               ->setSecret($robot['secret'])
                               ->setMessage(new CardMessage($card))
                               ->send();
                    }
                }
            }

            logInfo("当月开发确址排行榜数据推送完成", collect([]), true, true);
        }
    }

    //全国
    public function getRobot(): array
    {
        if (self::isProd()) {

            // 大 群
            return [
                'url'      => 'https://open.feishu.cn/open-apis/bot/v2/hook/95ea3435-8024-48ac-b318-7bea6178f606',
                'urlToken' => '95ea3435-8024-48ac-b318-7bea6178f606',
                'secret'   => '30GPCPHLAauseAvFjWHwEb'
            ];
        } else {

            // qa 群
            return self::getQaRobot();
        }
    }

    public function isProd(): bool
    {
        if ('prod' == $this->argument('env') && config('app.env') == 'prod') {
            return true;
        } else {
            return false;
        }
    }


    //分公司
    public function getBranchRobot(): array
    {
        if (self::isProd()) {

            // 大 群
            return [
                'url'      => 'https://open.feishu.cn/open-apis/bot/v2/hook/4e61e402-7e1e-468b-8e38-ab3a2a6187aa',
                'urlToken' => '4e61e402-7e1e-468b-8e38-ab3a2a6187aa',
                'secret'   => 'kTLG4fe4Gz7GbWdDXBpxQf'
            ];
        } else {

            // qa 群
            return self::getQaRobot();
        }
    }


    //qa 群
    public function getQaRobot(): array
    {

        /*return [
            'url'      => 'https://open.feishu.cn/open-apis/bot/v2/hook/cfb3d040-7290-4f2e-8125-29bc2ecefd21',
            'urlToken' => 'cfb3d040-7290-4f2e-8125-29bc2ecefd21',
            'secret'   => 'wJVvEiVhDAbn3Z7tDFqG6d'
        ];*/
        //        推送专题群
        return [
            'url'      => 'https://open.feishu.cn/open-apis/bot/v2/hook/5e9aed06-0e5f-4c23-b895-313cc8fff580',
            'urlToken' => '5e9aed06-0e5f-4c23-b895-313cc8fff580',
            'secret'   => 'OLyolDO3rcfxFQZYGBFNPb'
        ];
    }
}



